
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xin_he/utils/xin_he_input_widget.dart';

import '../../../utils/xh_styles.dart';
import '../../../utils/xin_he_image.dart';
import 'xin_he_seller_enter_logic.dart';

class XinHeSellerEnterPage extends StatelessWidget {
  XinHeSellerEnterPage({Key? key}) : super(key: key);

  final logic = Get.put(XinHeSellerEnterLogic());
  final state = Get.find<XinHeSellerEnterLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        leading: IconButton(
            onPressed: (){
              Get.back();
            },
            icon: Container(
              padding: const EdgeInsets.only(left: 7),
              alignment: Alignment.centerLeft,
              child: const XinHeAssetImage(
                'assets/images/home/app_back_3.png',
                width: 9.5,
                height: 17,
                fit: BoxFit.cover,),
            )
        ),
        backgroundColor: Colors.white,
        shadowColor: Colors.transparent,
        title: Text('商家入驻',style: TextStyle(color:XinHeColor('#222222'),fontSize: 17,fontWeight: FontWeight.w600)),
        centerTitle: true,
      ),
      body:   Stack(children: [
        Column(children: [
          _itemView('*店铺名称', '请输入店铺名称', (data) { logic.shopNameChange(data);}),
          _itemView('*店铺logo', '', (data) { ;},addLogo: true),
          _itemView('*主营项目', '请输入主营项目', (data) { logic.shopManagerScopeChange(data);}),
          _itemView('*联系人', '请输入您的称呼', (data) { logic.shopContactNameChange(data);}),
          // _itemView('*手机号', '请输入您的手机号', (data) { logic.shopContactPhoneChange(data);}),
          Stack(
            children: [
              Container(
                width: Get.width,
                height: 78.5,
                color: Colors.white,
                padding: const EdgeInsets.symmetric(horizontal: 15),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('*手机号',style: TextStyle(color: XinHeColor('#454E4E'),fontSize: 14,fontWeight: FontWeight.w500),),

                    XinHeInputWidget('','请输入您的手机号' , (value){logic.shopContactPhoneChange(value);},isHiddenLine: true,keyboardType: TextInputType.phone,maxInputLength: 11,),

                  ],),

              ),
              Positioned(
                bottom: 0,
                left: 15,
                child: Container(
                  width: Get.width-30,
                  height: 0.5,
                  color:XinHeStyle.lineColor
                  ,),
              )
            ],
          )

        ],),

        Positioned(
          bottom: 0,
          width: Get.width,
          height: 22+10+45+Get.mediaQuery.padding.bottom+25,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
            Container(
              color: Colors.transparent,
              height: 22,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  GestureDetector(
                    onTap: (){
                      logic.changeSelectedStatus();
                    },
                    child:Obx(() =>  Padding(
                      padding: const EdgeInsets.symmetric(horizontal: 8,vertical: 4),
                      child:  XinHeAssetImage(state.selected.value ?'assets/images/login/login_selected.png':'assets/images/login/login_unselected.png',width: 14,height: 14,fit: BoxFit.fill),
                    )),
                  ),
                  // SizedBox(width: 3.w,),
                  RichText(
                    text: TextSpan(
                        children:
                        [


                          WidgetSpan(
                            child: GestureDetector(
                              // onTap: logic.toUserProtocolPage,
                              child: Text(
                                '我已阅读并同意平台',
                                style: TextStyle(
                                  color: XinHeColor("#8C8C8C"),
                                  fontSize: 14,
                                ),
                              ),
                            ),
                          ),
                          WidgetSpan(
                            child: GestureDetector(
                              onTap: (){

                              },
                              child: Text(
                                '《入驻申请协议》',
                                style: TextStyle(
                                  color: XinHeColor("#1CA6A1"),
                                  fontSize: 14,
                                ),
                              ),
                            ),
                          ),

                        ]
                    ),
                  )

                ],
              ),
            ),
            const SizedBox(height: 10,),
            GestureDetector(
              onTap: (){
              },
              child: Container(
                margin:  const EdgeInsets.only(left: 15,right: 14,top: 0),
                height: 45,
                width: double.infinity,
                alignment: Alignment.center,
                decoration: BoxDecoration(color:  XinHeColor('#10C9C9'),borderRadius: BorderRadius.all(Radius.circular(22.5))),
                child: const Text (
                  "申请入驻",
                  style: TextStyle (fontSize: 16,color:  Colors.white,fontWeight: FontWeight.w600) ,
                ),),
            ),
            SizedBox(height: Get.mediaQuery.padding.bottom+25,),
          ],),
        )
      ],),

    );
  }

  Widget _itemView(String title,String hintText,Function callback,{bool addLogo = false,bool isPhoneNum = false}){
    return Stack(
      children: [
        Container(
          width: Get.width,
          height: 78.5,
          color: Colors.white,
          padding: const EdgeInsets.symmetric(horizontal: 15),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(title,style: TextStyle(color: XinHeColor('#454E4E'),fontSize: 14,fontWeight: FontWeight.w500),),

              addLogo?Padding(
                padding: const EdgeInsets.symmetric(vertical: 7.5),
                child: const XinHeAssetImage('assets/images/mine/seller_add.png',width:30,height: 30 ,),
              )
                  : XinHeInputWidget('', hintText, (value){callback(value);},isHiddenLine: true,),

            ],),

        ),
        Positioned(
          bottom: 0,
          left: 15,
          child: Container(
            width: Get.width-30,
            height: 0.5,
            color:XinHeStyle.lineColor
            ,),
        )
      ],
    );
  }
}
